package com.zkdcloud.repository;

import com.zkdcloud.domain.CartDiscount;
import org.jfaster.mango.annotation.DB;
import org.jfaster.mango.annotation.SQL;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zk123
 * @version 2018/5/23
 */
@DB(table = "cart_discount")
@Repository
public interface CartDiscountDao {
    String COLUMNS = "id,cart_id,name,price,description,icon_name,icon_color,create_time";

    /**
     * 添加优惠
     *
     * @param cartDiscount cartDiscount
     */
    @SQL("insert into #table(" + COLUMNS + ")values(:id,:cartId,:name,:price,:description,:iconName,:iconColor,:createTime)")
    void add(CartDiscount cartDiscount);

    /**
     * 根据购物车id获取
     *
     * @param id id
     * @return cartDiscount
     */
    @SQL("select * from #table where cart_id = :1")
    List<CartDiscount> getAllByCartId(String id);
}
